package com.common.broadcastRecever;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;


/**
 * 作者：小白 on 2017/6/15 18:09
 * 说明:
 */

public class ScanDataBroadcastReceiver extends BroadcastReceiver {
    PdaCallBack pdaCallBack;

    public ScanDataBroadcastReceiver(PdaCallBack pdaCallBack) {
        this.pdaCallBack = pdaCallBack;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        int keycode = intent.getIntExtra("Scan_Keycode", 0);
        if (action.equals("com.android.scancontext")){
            // “前台输出”不打勾时，不会发送此Intent
            String str = intent.getStringExtra("Scan_context");
            String type = intent.getStringExtra("Scan_type");
        } else if (action.equals("com.android.scanservice.scancontext")) {
            String str = intent.getStringExtra("Scan_context");
            String type = intent.getStringExtra("Scan_type");
            if (pdaCallBack!=null)
                pdaCallBack.setinfo(str);
        }
    }
    public interface PdaCallBack{
        void setinfo(String s);
    }
}
